<?php

/**
 * Position form.
 *
 * @package    virtualstore
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class PositionForm extends BasePositionForm {

    public function configure() {
        $this->resetStamps();
        $currentEmployeeId =null;
        $et = Doctrine_Core::getTable('Employee');
        if ($this->isNew()) {            
            $query = $et->getInactiveEmployeesQuery();
            $options = array('model' => $this->getRelatedModelName('Employee'),
                'add_empty' => true,
                'query' => $query);

            $this->setWidget('employee_id', new sfWidgetFormDoctrineChoice($options));
        }else{         
            $currentEmployeeId = $this->getObject()->getEmployeeId();
            $query = $et->getInactiveEmployeesQuery($currentEmployeeId);
            $options = array('model' => $this->getRelatedModelName('Employee'),
                'add_empty' => $currentEmployee,
                'query' => $query);

            $this->setWidget('employee_id', new sfWidgetFormDoctrineChoice($options));
        }
    }

}
